package com.zyd.shiro.business.controller.pak;

import com.github.pagehelper.PageInfo;
import com.zyd.shiro.business.entity.TransferLine;
import com.zyd.shiro.business.service.PakTransferLineService;
import com.zyd.shiro.framework.object.BaseConditionVO;
import com.zyd.shiro.framework.object.PageResult;
import com.zyd.shiro.framework.object.ResponseVO;
import com.zyd.shiro.persistence.beans.PakMigrateLine;
import com.zyd.shiro.util.ResultUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.zyd.shiro.persistence.beans.PakTransferLine;
import io.swagger.annotations.ApiOperation;

import java.util.List;
import java.io.File;
import com.zyd.shiro.utils.FileUtils;
import com.zyd.shiro.utils.ExcelUtil;
import java.util.Date;


@RestController
@RequestMapping("/transferLine")
@Api(description = "资产调拨明细")
public class PakTransferLineController {
    @Autowired
    private PakTransferLineService transferLineService;

    @PostMapping
    @ApiOperation(value="添加", produces="application/json")
    public ResponseVO insert(TransferLine transferLine) {
        transferLineService.insert(transferLine);
        return ResultUtil.success("添加成功！",null);
    }

    @PutMapping
    @ApiOperation(value="修改", produces="application/json")
    public ResponseVO update(TransferLine transferLine) {
        transferLineService.updateSelective(transferLine);
        return ResultUtil.success("修改成功！",null);
    }

    @DeleteMapping(value = "/{id}")
    @ApiOperation(value="主键删除", produces="application/json")
    public ResponseVO delete(@PathVariable(name="id") Long id){
        transferLineService.removeByPrimaryKey(id);
        return ResultUtil.success("删除成功！",null);
    }

    @GetMapping
    @ApiOperation(value="分页查询", produces="application/json")
    public PageResult page(BaseConditionVO vo) {
        PageInfo<TransferLine> pageInfo = transferLineService.findPageBreakByCondition(vo);
        return ResultUtil.tablePage(pageInfo);
    }

    @GetMapping(value = "/all")
    @ApiOperation(value="查询所有", produces="application/json")
    public ResponseVO list() {
        List<TransferLine> transferLines = transferLineService.listAll();
        return ResultUtil.success("查询成功！",transferLines);
    }
    @GetMapping(value = "/transfer/{id}")
    @ApiOperation(value="外键查询明细列表", produces="application/json")
    public ResponseVO findById(@PathVariable(name="id") Long id) {
        List<PakTransferLine> pakTransferLines = transferLineService.findByTransfer(id);
        return ResultUtil.success("查询成功！",pakTransferLines);
    }
}